<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html>
<head>
	<base th:href="@{/}"><!-- 不用base就使用th:src="@{/js/jquery.min.js} -->
	<meta charset="UTF-8">
	<title>注册</title>
	<link rel="stylesheet" type="text/css" href="css/public.css"/>
	<link rel="stylesheet" type="text/css" href="css/login.css"/>
	<link rel="stylesheet" href="layui/css/modules/layer/default/layer.css">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
	<script src="js/jquery.min.js"></script>
	<script src="js/common.js"></script>
	<script src="layui/layui.js"></script>
</head>
	<body>
		<!-------------------reg-------------------------->
		<div class="reg">
			<form action="false">
				<a th:href="@{/}"><h1><img src="img/temp/logo.png"></h1></a>
				<p style="font-size: 25px">邮箱验证登录</p>
				<p><input type="text" id="email" name="" value="" placeholder="请输入邮箱"></p>
				<p class="txtL txt">
					<input type="button" id="sendBtn" class="btn btn-primary" value="发送邮箱验证码" >
					<br><br>
					<input class="code" type="text" id="eCode" name="" value="" placeholder="输入验证码">
				</p>
				<p><input type="button" id="emailLoginBtn" class="btn btn-primary" name="" value="登录"></p>
				<p><input type="button" id="userNameLogin" class="btn btn-primary" name="" value="用户名登录"></p>
				<!--<p class="txtL txt"><a href="#">使用条款和隐私策略</a></p>-->
				<p class="txt"><a th:href="@{user/toReg}"><span></span>尚未注册？</a></p>
			</form>
		</div>
	</body>
<script>
	//-------------验证邮箱输入是否为空----------------
	$("#email").blur(function () {
		//验证是否为空
		var email=$("#email").val();
		if (email==null||email==""){
			layer.msg("请填写邮箱");
			return;
		}
	});

	//-----------------------发送邮件事件----------------------
	$("#sendBtn").click(function () {
		var email = $("#email").val();
		$.post("/furniture/user/sendEmail",{"email":email},function (data) {
			layer.msg(data.message);
		});
	});

	//-------------------------跳转至用户名登录-------------------
	$("#userNameLogin").click(function () {
		location.href = "/furniture/user/toLogin";
	});

	//-------------------邮箱登录-----------------------------
	$("#emailLoginBtn").click(function () {
		var email = $("#email").val();
		var eCode = $("#eCode").val();
		var url = "/furniture/user/doEmailLogin";
		param = {"email":email,"eCode":eCode};
		$.post(url,param,function (data) {
			if (data.state==200){
				location.href="/furniture/";
			}else {
				layer.msg(data.message);
			}
		});
	});
</script>
</html>
